package com.glance.browser.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.glance.browser.domain.Author;
import com.glance.browser.domain.KnowledgeItem;
import com.glance.browser.repository.AuthorRepository;

@Repository
@Transactional(readOnly = true)
public class AuthorDAOImpl implements AuthorDAO {

	@Autowired
	private AuthorRepository repository;

	public List<KnowledgeItem> findKnowledgeItemsById (Long id){
		return repository.findKnowledgeItemsById(id);
	}
	
	public List<KnowledgeItem> findKnowledgeItemsByFirstAndLastName (String user, String pass){
		return repository.findKnowledgeItemsByFirstAndLastName(user, pass);
	}
	
	public Author findByName(String firstName, String lastName){
		return repository.findByName(firstName, lastName);
	}

	@Transactional
	public Author save(Author author) {
		return repository.save(author);
	}

	@Transactional
	public void delete(Author author) {
		repository.delete(author);
	}

}
